const express = require("express");
const router = express.Router();
const { addBlogTypeServices, getBlogTypeServices, deleteOneBlogTypeServices, getOneBlogTypeServices, updateOneBlogTypeServices } = require("../services/blogTypeServices");
// 获取文章分类
router.get("/", async (req, res, next) => {
    res.send(await getBlogTypeServices());
})

// 添加文章分类
router.post("/", async (req, res, next) => {
    res.send(await addBlogTypeServices(req.body));
})

// 通过Id获取一个文章分类
router.get("/:id", async (req, res, next) => {
    res.send(await getOneBlogTypeServices(req.params.id))
})

// 通过Id修改一个文章分类
router.put("/:id", async (req, res, next) => {
    res.send(await updateOneBlogTypeServices(req.params.id, req.body));
})

// 通过Id删除一个文章分类
router.delete("/:id", async (req, res, next) => {
    res.send(await deleteOneBlogTypeServices(req.params.id));
})

module.exports = router;